#include <stdio.h>

int main()
{
    char buffer[1024];
    FILE *pipe = popen("netstat -napt | grep 3306", "r");
    if (!pipe)
    {
        perror("popen");
        return 1;
    }
    while (fgets(buffer, sizeof(buffer), pipe) != NULL)
    {
        printf("%s", buffer);
    }
    return 0;
}